package com.hzo.great.leisuregreat.utils;

import android.widget.ImageView;


import com.hzo.great.leisuregreat.R;

import org.xutils.common.util.DensityUtil;
import org.xutils.image.ImageOptions;
import org.xutils.x;


/**
 * Created by Administrator on 2016/9/21.
 */
public class ImagexUtils {
    static ImageOptions options = new ImageOptions.Builder()
            .setCrop(true)
            .setUseMemCache(false)
            .setImageScaleType(ImageView.ScaleType.FIT_XY)
            .setLoadingDrawableId(R.mipmap.shouji)
            .setFailureDrawableId(R.mipmap.shouji).build();

    static ImageOptions option4 = new ImageOptions.Builder()
            .setCrop(true)
            .setUseMemCache(false)
            .setImageScaleType(ImageView.ScaleType.FIT_XY)
            .build();


    static ImageOptions image = new ImageOptions.Builder()
            .setCrop(true)
            .setImageScaleType(ImageView.ScaleType.FIT_XY)
            .setLoadingDrawableId(R.mipmap.shouji)
//            .setSize(DensityUtil.dip2px(90), DensityUtil.dip2px(90))
            .setRadius(DensityUtil.dip2px(3))
            .setFailureDrawableId(R.mipmap.shouji).build();

//    static ImageOptions optionsR = new ImageOptions.Builder()
//            .setSize(DensityUtil.dip2px(90), DensityUtil.dip2px(90))
//            .setRadius(DensityUtil.dip2px(45))
//            .setCrop(true)
//            .setUseMemCache(true)
//            .setImageScaleType(ImageView.ScaleType.CENTER_CROP)
//            .setLoadingDrawableId(R.mipmap.ic_launcher)
//            .setFailureDrawableId(R.mipmap.ic_launcher).build();
//    static ImageOptions options1 = new ImageOptions.Builder()
//            .setImageScaleType(ImageView.ScaleType.FIT_XY)
//            .setLoadingDrawableId(R.mipmap.ic_launcher)
//            .setFailureDrawableId(R.mipmap.ic_launcher).build();
//    static ImageOptions options2 = new ImageOptions.Builder()
//            .setSize(DensityUtil.dip2px(180), DensityUtil.dip2px(90))
//            .setCrop(true)
//            .setUseMemCache(true)
//            .setImageScaleType(ImageView.ScaleType.FIT_XY)
//            .setLoadingDrawableId(R.mipmap.ic_launcher)
//            .setFailureDrawableId(R.mipmap.ic_launcher).build();



    public static void setImg(ImageView imageview, String url) {
        x.image().clearCacheFiles();
        x.image().clearMemCache();
        x.image().bind(imageview, url, options);


    }

    public static void setImg1(ImageView imageview, String url) {

        x.image().bind(imageview, url, option4);


    }

    public static void setHead(ImageView imageview, String url) {
        x.image().bind(imageview, url, image);

    }
//    public static void setImgRadius(ImageView imageview, String url) {
//        x.image().bind(imageview, url, optionsR);
//
//    }
//
//    public static void setImg1(ImageView imageview, String url) {
//        x.image().bind(imageview, url, options1);
//
//    }
//    public static void setImg2(ImageView imageview, String url) {
//        x.image().bind(imageview, url, options2);
//    }

}
